dnl config.m4 for valhala module

define(valhala_required_version,   0.0.0)

PHP_GTK_ARG_ENABLE(valhala,for valhala support,
[  --enable-valhala       Enable valhala support])

dnl if test "$PHP_VALHALA" != "no"; then
dnl   for x in /usr /usr/local; do
dnl     if test -f $x/include/valhala.h; then
dnl       VALHALA_DIR=$x
dnl       VALHALA_INCDIR=$x/include
dnl     fi
dnl   done
dnl 
dnl   if test -z "$VALHALA_DIR"; then
dnl     AC_MSG_ERROR(Cannot locate valhala)
dnl   fi
dnl 
dnl   VALHALA_LIBDIR=$VALHALA_DIR/lib
dnl 
dnl   AC_DEFINE(HAVE_VALHALA,1,[valhala support])
dnl   PHP_ADD_INCLUDE($VALHALA_INCDIR)
dnl 
dnl   if test "$php_gtk_ext_shared" = "yes"; then
dnl     PHP_ADD_LIBRARY_WITH_PATH(valhala, $VALHALA_LIBDIR, VALHALA_SHARED_LIBADD)
dnl     PHP_SUBST(VALHALA_SHARED_LIBADD)
dnl   else
dnl     PHP_ADD_LIBRARY_WITH_PATH(valhala, $VALHALA_LIBDIR, PHP_GTK_SHARED_LIBADD)
dnl   fi
dnl   PHP_GTK_EXTENSION(valhala, $php_gtk_ext_shared, php_valhala.c, gen_valhala.c)
dnl fi

if test "$PHP_GTK_VALHALA" != "no"; then
  PKG_CHECK_MODULES(VALHALA, [libvalhala], have_valhala=yes, have_valhala=no)
  if test "$have_valhala" != "yes"; then
    AC_MSG_RESULT([Unable to locate valhala version valhala_required_version or higher: not building])
  else
    AC_DEFINE(HAVE_VALHALA, 1, [valhala support])
    PHP_EVAL_INCLINE($VALHALA_CFLAGS)
    if test "$php_gtk_ext_shared" = "yes"; then
      PHP_EVAL_LIBLINE($VALHALA_LIBS, PHP_VALHALA_SHARED_LIBADD)
      PHP_SUBST(PHP_VALHALA_SHARED_LIBADD)
    else
      PHP_EVAL_LIBLINE($VALHALA_LIBS, PHP_GTK2_SHARED_LIBADD)
    fi
    PHP_GTK_EXTENSION(valhala, $php_gtk_ext_shared, php_valhala.c, gen_valhala.c)
  fi
fi
